#include "../DataStructures/avdtech.h"

int xsubstr(char *str, char *sub, int n, int len) {
    char *p, *q=str;
    
    while (n) {
        p = strstr(str, sub);
        LOG(LOG_INFO, "n=%d str=[%s] p=[%s]\n", n, str, p);
        if (!p) return -1;
        n--;
        str = p + len;
    }

    LOG(LOG_INFO, "str=[%s] p=[%s]\n", str, p);

    return (str - q - len);
}

